package org.rcgwt.client.ui.grid;

import org.rcgwt.client.ui.grid.model.IColumn;
import org.rcgwt.client.ui.grid.model.IDataModel;
import org.rcgwt.client.ui.grid.model.IFiltredDataModel;
import org.rcgwt.client.ui.grid.model.IGroupDataModel;
import org.rcgwt.client.ui.grid.provider.BasicColumnProvider;
import org.rcgwt.client.ui.grid.provider.IAdditionalInformationProvider;
import org.rcgwt.client.ui.grid.provider.ICheckProvider;
import org.rcgwt.client.ui.grid.provider.IColumnProvider;
import org.rcgwt.client.ui.grid.provider.IFocusProvider;
import org.rcgwt.client.ui.grid.provider.IOrderProvider;
import org.rcgwt.client.ui.grid.provider.IOverProvider;
import org.rcgwt.client.ui.grid.provider.ISelectionProvider;
import org.rcgwt.client.ui.grid.theme.DefaultGridTheme;
import org.rcgwt.client.ui.grid.theme.IGridTheme;

/**
 * Base config for {@link RcGrid}
 * 
 * @author Matthieu ROBERT & Olivier Oeuillot
 * 
 */
public class RcGridConfig {

    // Model
    private IDataModel dataModel = null;

    private IFiltredDataModel filtredDataModel = null;

    private IGroupDataModel groupDataModel = null;

    private boolean editable = false;

    private boolean selectable = true;

    private boolean checkable = false;

    private boolean additionalInformations = false;

    // Default Renderer
    private IGridTheme theme = null;

    private int width = 500;

    private int height = 300;

    private int firstRowIndex = 0;

    private int pageSize = -1;

    private IColumnProvider columnProvider = null;

    private ISelectionProvider selectionProvider;

    private ICheckProvider checkProvider;

    private IAdditionalInformationProvider additionalInformationProvider;

    private IOverProvider overProvider;

    private IFocusProvider focusProvider;

    private IOrderProvider columnsOrderProvider;

    private boolean focusAutoSelect = true;

    public IDataModel getDataModel() {
        return dataModel;
    }

    public void setDataModel(IDataModel dataModel) {
        this.dataModel = dataModel;
    }

    public IFiltredDataModel getFiltredDataModel() {
        return filtredDataModel;
    }

    public void setFiltredDataModel(IFiltredDataModel filtredDataModel) {
        this.filtredDataModel = filtredDataModel;
    }

    public IGroupDataModel getGroupDataModel() {
        return groupDataModel;
    }

    public void setGroupDataModel(IGroupDataModel groupDataModel) {
        this.groupDataModel = groupDataModel;
    }

    public boolean isEditable() {
        return editable;
    }

    public void setEditable(boolean editable) {
        this.editable = editable;
    }

    public boolean isSelectable() {
        return selectable;
    }

    public void setSelectable(boolean selectable) {
        this.selectable = selectable;
    }

    public boolean isCheckable() {
        return checkable;
    }

    public void setCheckable(boolean checkable) {
        this.checkable = checkable;
    }

    public boolean isAdditionalInformations() {
        return additionalInformations;
    }

    public void setAdditionalInformations(boolean additionalInformations) {
        this.additionalInformations = additionalInformations;
    }

    public IGridTheme getTheme() {
        if (theme == null) {
            theme = DefaultGridTheme.getTheme();
        }
        return theme;
    }

    public void setTheme(IGridTheme theme) {
        this.theme = theme;
    }

    public int getFirstRowIndex() {
        return firstRowIndex;
    }

    public void setFirstRowIndex(int firstRowIndex) {
        this.firstRowIndex = firstRowIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public IColumn addColumn(String name, String title) {
        if (columnProvider == null) {
            columnProvider = new BasicColumnProvider();
        }
        return getColumnProvider().addColumn(name, title);
    }

    public void setColumnProvider(IColumnProvider columnProvider) {
        this.columnProvider = columnProvider;
    }

    public IColumnProvider getColumnProvider() {

        return columnProvider;
    }

    public int getWidth() {
        return this.width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getHeight() {
        return height;
    }

    public ISelectionProvider getSelectionProvider() {
        return selectionProvider;
    }

    public void setSelectionProvider(ISelectionProvider selectionProvider) {
        this.selectionProvider = selectionProvider;
    }

    public ICheckProvider getCheckProvider() {
        return checkProvider;
    }

    public void setCheckProvider(ICheckProvider checkProvider) {
        this.checkProvider = checkProvider;
    }

    public IAdditionalInformationProvider getAdditionalInformationProvider() {
        return additionalInformationProvider;
    }

    public void setAdditionalInformationProvider(
            IAdditionalInformationProvider additionalInformationProvider) {
        this.additionalInformationProvider = additionalInformationProvider;
    }

    public IOverProvider getOverProvider() {
        return overProvider;
    }

    public void setOverProvider(IOverProvider overProvider) {
        this.overProvider = overProvider;
    }

    public IFocusProvider getFocusProvider() {
        return focusProvider;
    }

    public void setFocusProvider(IFocusProvider focusProvider) {
        this.focusProvider = focusProvider;
    }

    public boolean isFocusAutoSelect() {
        return focusAutoSelect;
    }

    public void setFocusAutoSelect(boolean focusAutoSelect) {
        this.focusAutoSelect = focusAutoSelect;
    }

    public IOrderProvider getColumnsOrderProvider() {
        return columnsOrderProvider;
    }

    public void setColumnsOrderProvider(IOrderProvider columnsOrderProvider) {
        this.columnsOrderProvider = columnsOrderProvider;
    }

}
